package springboard.auth.bean;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.security.Principal;
import java.util.Date;

@Data
public class Account implements Principal, Serializable {

    @ApiModelProperty("用户名")
    @TableId(type = IdType.INPUT)
    String username;

    @ApiModelProperty("密码（加密）")
    @TableField(updateStrategy = FieldStrategy.NOT_NULL)
    String password;

    @ApiModelProperty("密码（明文）")
    @TableField(exist = false)
    String plainPassword;

    @ApiModelProperty("用户ID")
    Long userId;

    @ApiModelProperty("创建时间")
    Date createdTime;

    @ApiModelProperty("更新时间")
    Date updatedTime;

    @ApiModelProperty("最近登录时间")
    Date lastLoggedInTime;

    @ApiModelProperty("最近登录IP")
    String lastLoggedInAddr;

    @TableField(exist = false)
    private User user;

    @Override
    public String getName() {
        return username;
    }

}
